package com.aliwo.listener;

import com.aliwo.event.MyTestEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * .
 *
 * @author Xu Yayuan
 */
@Component
public class MyAnnotationListener {

    @EventListener
    public void listener1(MyTestEvent event) {
        System.out.println("注解监听器2:" + event.getMsg());
    }

    @EventListener
    @Async
    public void listener2(MyTestEvent event) {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("异步注解监听器2:" + event.getMsg());
    }
}
